home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / common1r / form1.frm next >
Text File  |  1999-08-26  |  4KB  |  119 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "DasherSW's Moving Caption Sample..."
  4.    ClientHeight    =   525
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4875
  8.    LinkTopic       =   "Form1"
  9.    MaxButton       =   0   'False
  10.    Moveable        =   0   'False
  11.    ScaleHeight     =   525
  12.    ScaleWidth      =   4875
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.Timer Timer1 
  15.       Left            =   0
  16.       Top             =   0
  17.    End
  18.    Begin VB.CommandButton Start 
  19.       Caption         =   "Start"
  20.       Height          =   495
  21.       Left            =   420
  22.       TabIndex        =   0
  23.       Top             =   0
  24.       Width           =   1215
  25.    End
  26.    Begin VB.Label Label1 
  27.       BackStyle       =   0  'Transparent
  28.       Caption         =   "You can place Start_Click in Form_Load so that it starts to move just after form is loaded."
  29.       Height          =   435
  30.       Left            =   1680
  31.       TabIndex        =   1
  32.       Top             =   60
  33.       Width           =   3135
  34.    End
  35. End
  36. Attribute VB_Name = "Form1"
  37. Attribute VB_GlobalNameSpace = False
  38. Attribute VB_Creatable = False
  39. Attribute VB_PredeclaredId = True
  40. Attribute VB_Exposed = False
  41. Rem Code by DasherSW. 'Hope i' will teach u some.
  42. Rem know this variables declared at first will always work
  43. Rem faster than getting the needed value at run time.
  44. Rem Const values cannot change.
  45. Rem
  46. Rem declarations
  47. Rem
  48. Rem the amount of spaces the caption will move left
  49. Const CapSpace As Integer = 10
  50. Rem the interval of the timer
  51. Const TimerInt As Integer = 50
  52. Rem if its in phase of moving right
  53. Dim MovRight As Boolean
  54. Rem if its in phase of disappearing into right
  55. Dim Disapear As Boolean
  56. Rem if its in phase of reappearing from left
  57. Dim StartAga As Boolean
  58. Rem the length of caption
  59. Dim CaptiLen As Integer
  60. Rem default caption.
  61. Dim DefCapti As String
  62.  
  63. Private Sub Form_Load()
  64. CaptiLen = Len(Form1.Caption)
  65. DefCapti = Form1.Caption
  66. End Sub
  67.  
  68. Private Sub Start_Click()
  69. MovRight = True
  70. Disapear = False
  71. StartAga = False
  72. Timer1.Interval = TimerInt
  73. End Sub
  74.  
  75. Private Sub Timer1_Timer()
  76. Rem make i a loop variable
  77. Static i As Integer
  78. Rem if i is equal to capspace then start disapear phase
  79. If i = CapSpace Then
  80. i = 0
  81. MovRight = False
  82. Disapear = True
  83. End If
  84. Rem if still in movright phase and i < capspace then
  85. If MovRight = True Then
  86. Form1.Caption = Space(1) & Form1.Caption
  87. Rem increase value of i one by one to make it equal to capspace
  88. i = i + 1
  89. End If
  90. Rem if disapear phase (if the caption must disapear through right now)
  91. If Disapear = True Then
  92. Rem give caption 2 spaces from left and take one letter from right
  93. Form1.Caption = Space(2) & Left(Form1.Caption, (Len(Form1.Caption) - 1))
  94. End If
  95. Rem if all of the visible (excluding spaces) caption has disappeared
  96. If Len(Form1.Caption) = CaptiLen + CaptiLen + CapSpace Then
  97. Disapear = False
  98. Rem start the StartAgain phase
  99. StartAga = True
  100. End If
  101. Rem if start again phase has started then
  102. If StartAga = True Then
  103. Static r
  104. Rem make form1 caption to get each letter from right of the DefCapti.
  105. Rem defcapti here helps us to reappear the true caption.
  106. Rem if you don't like to use this easier way, the defcapti,
  107. Rem you can count spaces and leave them off to take the cap.
  108. Form1.Caption = Right(DefCapti, r)
  109. r = r + 1
  110. End If
  111. Rem if form1 caption = the first caption then
  112. If Form1.Caption = DefCapti Then
  113. Rem r=0 so that the cap will not move forever in the 3rd loop.
  114. r = 0
  115. Rem start everything again....
  116. Start_Click
  117. End If
  118. End Sub
  119.